﻿using System;
using System.Collections;

namespace ArrayListTest
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList list1 = new ArrayList(){
                "aaa", "bbb", "abc", 123, 456 };
            int index = list1.IndexOf("abc");
            if (index != -1)
            {
                Console.WriteLine("集合中存在 abc 元素！");
            }
            else
            { Console.WriteLine("集合中不存在 abc 元素！"); }



            ArrayList list2 = new ArrayList()
            {"aaa", "bbb", "abc", 123, 456 };
            ArrayList newList = new ArrayList();
            for (int i = 0; i < list2.Count; i = i + 2)
            {
                newList.Add(list2[i]);
            }
            foreach (var v in newList)
            {
                Console.WriteLine(v);
            }



            ArrayList list = new ArrayList() {
                "aaa", "bbb", "abc", 123, 456 };
            ArrayList insertList = new ArrayList() {
                "A", "B", "C" };
            list.InsertRange(1, insertList);
            foreach (var v in list)
            {
                Console.WriteLine(v);
            }



            ArrayList list3 = new ArrayList() {
                "aaa", "bbb", "abc" };
            list3.Sort();
            foreach (var v in list)
            {
                Console.WriteLine(v);
            }




        }
    }
}
    

    

